//
//  JCLogUtil.swift
//  JCPublicKit
//
//  Created by JasonLee on 2020/5/15.
//

import Foundation

class JCLog: NSObject {
    static var isLoggingEnabled: Bool {
        #if DEBUG
            return true
        #else
            return false
        #endif
    }
    
    static func verbose(_ content: String?, beautify: Bool = true, file: String = #file, functionName: String = #function, line: Int = #line) {
        guard isLoggingEnabled else { return }
        
        if beautify {
            let dateFormatter = DateFormatter()
            dateFormatter.dateFormat = "YYYY-MM-dd HH:mm:ss"
            print("[\(dateFormatter.string(from: Date()))]\n> \(functionName) [line \(line)]\n\(content ?? "nil")\n")
        } else {
            print("\(content ?? "nil")\n")
        }
    }
}
/**
 Will print content with beautify form in console.
 - parameter content: Content that will be printed.
 */
func jc_verbose(_ content: String?, file: String = #file, functionName: String = #function, line: Int = #line) {
    JCLog.verbose(content, beautify: true, file: file, functionName: functionName, line: line)
}
/**
 Will print content with beautify form in console.
 - parameter content: Content that will be printed.
 */
func jc_beautifyLog(_ content: String?, file: String = #file, functionName: String = #function, line: Int = #line) {
    jc_verbose(content, file: file, functionName: functionName, line: line)
}
/**
 Will print content only in console.
 - parameter content: What will be printed in console.
 */
func jc_log(_ content: String?, file: String = #file, functionName: String = #function, line: Int = #line) {
    JCLog.verbose(content, beautify: false, file: file, functionName: functionName, line: line)
}
